package ru.cod.rs;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class MainView extends SurfaceView implements SurfaceHolder.Callback {
	private SurfaceHolder holder;

	public MainView(Context context) {
		super(context);
		holder = getHolder();
		holder.addCallback(this);
	}

	@Override
	public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
		// TODO Auto-generated method stub

	}

	@Override
	public void surfaceCreated(SurfaceHolder arg0) {
		Canvas c = null;
		try {
			c = holder.lockCanvas();
			synchronized (holder) {
				c.drawColor(Color.BLUE);
			}
		} catch (Exception e) {
		} finally {
			if (c != null) {
				getHolder().unlockCanvasAndPost(c);
			}
		}
		// thread = new MainThread(getContext(), this);
		// thread.c();
		// thread.start();
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder arg0) {
		// thread.p();
		// boolean retry = true;
		// while (retry) {
		// try {
		// thread.join();
		// retry = false;
		// } catch (InterruptedException e) {
		// e.printStackTrace();
		// }
		// }
	}
}
